define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'microend/user_real/index',
                    add_url: 'microend/user_real/add',
                    edit_url: 'microend/user_real/edit',
                    del_url: 'microend/user_real/del',
                    multi_url: 'microend/user_real/multi',
                    table: 'user_real',
                    ajax_url: {
                        btn_7: 'microend/user_real/real'
                    },
                    btn_mall_window: {
                        btn_array: ["通过", "驳回","取消"],//"禁用",
                        btn_evn_array_length: 3,
                        btn_evn_array: {
                            evn_1: function (index, layero) {
                                var frame = Layer.getChildFrame('html', index);
                                var form = $("form", frame);
                                form.append(" <input name=\"type\"  value=\"2\" style=\"display: none\">");
                                var success = function () {
                                    table.bootstrapTable('refresh');
                                    Layer.close(index);
                                }
                                Fast.api.form_ajax_submit(form, success);
                            },//通过操作
                            evn_2: function (index, layero) {
                                var frame = Layer.getChildFrame('html', index);
                                var form = $("form", frame);
                                form.append(" <input name=\"type\"  value=\"3\" style=\"display: none\">");
                                var success = function () {
                                    table.bootstrapTable('refresh');
                                    Layer.close(index);
                                }
                                Fast.api.form_ajax_submit(form, success);
                            },//驳回操作
                            // evn_3: function (index, layero) {
                            //     var frame = Layer.getChildFrame('html', index);
                            //     var form = $("form", frame);
                            //     console.log(123);
                            //     form.append(" <input name=\"type\"  value=\"4\" style=\"display: none\">");
                            //     var success = function () {
                            //         table.bootstrapTable('refresh');
                            //         Layer.close(index);
                            //     }
                            //     Fast.api.form_ajax_submit(form, success);
                            // },//禁用
                            evn_4: function (index, layero) {
                                Layer.close(index);
                            }//取消
                        },
                        area: ['800px', '600px']
                    }


                }

            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'real_id',
                sortName: 'real_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'username', title: __('Username'),operate: 'like'},
                        {field: 'tao_bao_no', title: __('Tao_bao_no')},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'role', title: __('Role'),searchList: {"grouper":"组长","user":"组员"}, formatter: Table.api.formatter.normal},
                        {field: 'task_count', title: __('Task_day_count')},
                        {field: 'month_task_count', title: __('Month_task_count')},
                        {field: 'balance', title: __('Balance')},
                        {field: 'task_limit_cash', title: __('Task_limit_cash')},
                        {field: 'single_status',  title: __('Single_status'),searchList: {"1":"可接单","2":"不可接单"},formatter: Table.api.formatter.normal},
                        {field: 'cash_status',  title: __('Cash_status'), searchList: {"1":"可以","2":"不可以"},formatter: Table.api.formatter.normal},
                        {field: 'real_status', title: __('Real_status'),searchList: {"1":"审核中","2":"认证通过","3":"驳回","4":"禁用"},formatter: Table.api.formatter.normal},
                        {field: 'remarks', title: __('Remarks')},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter:function(value,row,index){

                                var table = this.table;
                                // 操作配置
                                var options = table ? table.bootstrapTable('getOptions') : {};

                                // 默认按钮组
                                var buttons = $.extend([], this.buttons || []);
                                if(row.real_status==1) {
                                    buttons.push(
                                        {
                                            name: 'btn_auth',
                                            text: "审核",
                                            extend: 'data-toggle="tooltip" data-name="btn_7" data-title="派客审核" ',
                                            classname: 'btn btn-xs btn-success btn-magic btn-small-window',
                                        });
                                    return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
                                }

                            }
                        }
                    ]
                ]
            });

            

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();

        },
        real:function(){
            $(function(){
                //console.log($(".example2"))
                require(['img_css/easy-loading','img_css/hammer.min','img_css/jquery.mousewheel.min','img_css/zoom-marker'],function(){
                    // $('#zoom-marker-img').zoomMarker({
                    //     src: $('#zoom-marker-img').data("url"),
                    //     rate: 0.2,
                    //     width: 100,
                    //     max: 1000,
                    //     markers:[
                    //         //{src:"img/marker.svg", x:500, y:500}
                    //     ]
                    // });
                    $("img").each(function(){
                        console.log($(this).data("url"));
                        if($(this).data("url")!=undefined && $(this).data("url")!="") {
                            $(this).zoomMarker({
                                src: $(this).data("url"),
                                rate: 0.1,
                                min: 100,
                                width: 100,
                                max: 3000,
                                markers: [
                                    //{src:"img/marker.svg", x:500, y:500}
                                ],
                            });
                        }
                    });
                    // $('#zoom-marker-img-alt').zoomMarker({
                    //     src: $('#zoom-marker-img-alt').data("url"),
                    //     rate: 0.1,
                    //     min:100,
                    //     width: 100,
                    //     max: 3000,
                    //     markers:[
                    //         //{src:"img/marker.svg", x:500, y:500}
                    //     ]
                    //
                    //
                    // });
                })
            });
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});